home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_mac.hqx / SRGP port to 5.0 (compressed) / SRGP_SPHIGS Root / MacSPHIGS / sph_draw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-13  |  3.6 KB  |  157 lines

  1. #include "HEADERS.h"
  2. #include "sphigslocal.h"
  3.  
  4. #include "sph_draw.proto.h"
  5. static void ChangeMCpointsToPDC3d_points(MAT3hvec *, pdc_point *, int);
  6. static void ChangeMCpointsToSRGP_points(MAT3hvec *, srgp__point *, int);
  7.  
  8.  
  9.  
  10. /** DRAW ROUTINES
  11. The display-traverser has set the two variables "currentViewIndex" and 
  12.     "currentCompositeModxform".
  13. **/
  14.  
  15.  
  16.  
  17. srgp__point srgp_pdc_points[20], srgp_polygon_points[20];
  18.  
  19.  
  20.  
  21. /*!*/
  22. static void ChangeMCpointsToPDC3d_points 
  23.    (MAT3hvec *MCvlist, pdc_point *PDCvlist, int vertex_count)
  24. {
  25.    register i;
  26.    MAT3hvec temp_outpt;
  27.  
  28.    for (i=(vertex_count-1); i>=0; i--) {
  29.       MAT3mult_hvec (temp_outpt, MCvlist[i], currentTOTALxform, 1);
  30.       PDCvlist[i][0] = (int)temp_outpt[0];
  31.       PDCvlist[i][1] = (int)temp_outpt[1];
  32.       PDCvlist[i][2] = (int)temp_outpt[2];
  33.    }
  34. }
  35.  
  36.  
  37. /*!*/
  38. static void ChangeMCpointsToSRGP_points 
  39.    (MAT3hvec *MCvlist, srgp__point *SRGP_vlist, int vertex_count)
  40. {
  41.    register i;
  42.    MAT3hvec temp_outpt;
  43.  
  44.    for (i=(vertex_count-1); i>=0; i--) {
  45.       MAT3mult_hvec (temp_outpt, MCvlist[i], currentTOTALxform, 1);
  46.       SRGP_vlist[i].x = (int)temp_outpt[0];
  47.       SRGP_vlist[i].y = (int)temp_outpt[1];
  48.    }
  49. }
  50.  
  51.  
  52.  
  53. /*!*/
  54. void
  55. SPH__draw_polyhedron (POLYHEDRON *poly, attribute_group *attrs)
  56. {
  57.    register int v, f, viindex;
  58.    pdc_point *vertptr;
  59.    vertex_index *viptr;
  60.    facet *facetptr;
  61.    obj *newobj;
  62.  
  63.    switch (currentRendermode) {
  64.  
  65.     case WIREFRAME_RAW:
  66.  
  67.       SRGP_setColor (attrs->edge_color);
  68.       SRGP_setLineWidth (attrs->edge_width);
  69.       SRGP_setLineStyle (attrs->edge_style);
  70.  
  71.       ChangeMCpointsToSRGP_points (poly->vertex_list, srgp_pdc_points,
  72.                    poly->vertex_count);
  73.  
  74.       for (f = 0, facetptr = poly->facet_list;
  75.        f < poly->facet_count;      
  76.        f++, facetptr++) {
  77.      viindex = facetptr->vertex_count;
  78.      viptr = facetptr->vertex_indices + viindex;
  79.      while (viindex--)
  80.         srgp_polygon_points[viindex] = srgp_pdc_points[*(--viptr)];
  81.      SRGP_polygon (facetptr->vertex_count, srgp_polygon_points);
  82.       }
  83.       break;
  84.  
  85.     default:
  86.       OBJECT__addPoly (currentViewSpec, poly, currentMCtoUVNxform, attrs);
  87.       break;
  88.    }
  89. }
  90.  
  91.  
  92. /*!*/
  93. void
  94. SPH__draw_fill_area (element *elptr, attribute_group *attrs)
  95. {
  96.    switch (currentRendermode) {
  97.  
  98.     case WIREFRAME_RAW:
  99.       SRGP_setColor (attrs->edge_color);
  100.       SRGP_setLineWidth (attrs->edge_width);
  101.       SRGP_setLineStyle (attrs->edge_style);
  102.       ChangeMCpointsToSRGP_points 
  103.      (elptr->data.points, srgp_pdc_points, elptr->info.count);
  104.       SRGP_polygon (elptr->info.count, srgp_pdc_points);
  105.       break;
  106.  
  107.     default:
  108.       OBJECT__addFillArea (currentViewSpec, 
  109.                elptr->data.points, elptr->info.count,
  110.                currentMCtoUVNxform, attrs);
  111.       break;
  112.    }
  113. }
  114.  
  115.  
  116.  
  117.  
  118. /*!*/
  119. void
  120. SPH__draw_lines (element *elptr, attribute_group *attrs)
  121. {
  122.    ChangeMCpointsToSRGP_points 
  123.       (elptr->data.points, srgp_pdc_points, elptr->info.count);
  124.  
  125.    SRGP_setColor (attrs->line_color);
  126.    SRGP_setLineStyle (attrs->line_style);
  127.    SRGP_setLineWidth (attrs->line_width);
  128.    SRGP_polyLine (elptr->info.count, srgp_pdc_points);
  129. }
  130.  
  131.  
  132.  
  133. /*!*/
  134. void
  135. SPH__draw_markers (element *elptr, attribute_group *attrs)
  136. {
  137.    ChangeMCpointsToSRGP_points 
  138.       (elptr->data.points, srgp_pdc_points, elptr->info.count);
  139.  
  140.    SRGP_setColor (attrs->marker_color);
  141.    SRGP_setMarkerStyle (attrs->marker_style);
  142.    SRGP_setMarkerSize (attrs->marker_size);
  143.    SRGP_polyMarker (elptr->info.count, srgp_pdc_points);
  144. }
  145.          
  146.       
  147.  
  148. /*!*/
  149. void
  150. SPH__draw_text (MAT3hvec mc_origin, char *text, attribute_group *attrs)
  151. {
  152.    ChangeMCpointsToSRGP_points ((MAT3hvec*)mc_origin, srgp_pdc_points, 1);
  153.    SRGP_setColor (attrs->text_color);
  154.    SRGP_setFont (attrs->font);
  155.    SRGP_text (srgp_pdc_points[0], text);
  156. }
  157.